package fr.emse.tatiana.display;


import java.awt.Color;

public class DisplayCell
{
    public String st;
    public DisplayIcon ic;
    public Color cc;  // cell color
    public Color fc;  // font color
    public Object ao; // some additionnal object to edit

    public DisplayCell()
    {
        st = "";
        ic = null;
        cc = null;
        fc = null;
        ao = null;
    }

    public DisplayCell(String s)
    {
        st = s;
        ic = null;
        cc = null;
        fc = null;
        ao = null;
    }

    public DisplayCell(DisplayIcon i)
    {
        st = "";
        ic = i;
        cc = null;
        fc = null;
        ao = null;
    }

    public DisplayCell(DisplayIcon i, String s)
    {
        st = s;
        ic = i;
        cc = null;
        fc = null;
        ao = null;
    }

    public DisplayCell(String s, Color c)
    {
        st = s;
        ic = null;
        cc = c;
        fc = null;
        ao = null;
    }

    public DisplayCell(String s, Color c, Color f)
    {
        st = s;
        ic = null;
        cc = c;
        fc = f;
        ao = null;
    }

    public DisplayCell(DisplayIcon i, String s, Color c, Color f)
    {
        st = s;
        ic = i;
        cc = c;
        fc = f;
        ao = null;
    }

    public DisplayCell(DisplayIcon i, String s, Color c, Color f, Object z)
    {
        st = s;
        ic = i;
        cc = c;
        fc = f;
        ao = z;
    }

    public DisplayCell(Object facet, org.eclipse.swt.graphics.Color fc) {
		this.fc = Ut.toAWTColor(fc.getRGB());
		st = facet.toString();
	}

	public void setIcon(DisplayIcon i)
    {
        ic = i;
    }

    @Override
	public String toString()
    {
    	return st;
    }
    

    public String toXMLString()
    {
    	return "<text" +
    	((fc != null) ? (" color=\"" + Ut.colorName(fc) + "\"") : "") +
    	((cc != null) ? (" bgcolor=\"" + Ut.colorName(cc) + "\"") : "") + ">" +
    	Ut.toXML(st) + "</text>";
    }
    
    public String toInfo(String name)
    {
    	return "info name=\"" + name + "\">" + toXMLString() + "</info>" ;
    }
}

